package view;


import java.awt.Frame;
import java.awt.Rectangle;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;

import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

import components.ComponentUtil;

public class UeberweisungDurchfuehrenDialog extends JDialog {

	private static final long serialVersionUID = 1L;

	private JPanel jContentPane = null;

	private JLabel jLabel = null;
	private JLabel jLabel1 = null;
	private JLabel jLabel2 = null;
	private JLabel jLabel3 = null;

	private JTextField tfKontoVon = null;
	private JTextField tfKontoNach = null;
	private JTextField tfBetrag = null;
	private JTextField tfDatum = null;

	private JButton btUeberweisung = null;
	private JButton btDatum = null;
	private JButton btEnde = null;


	public UeberweisungDurchfuehrenDialog(Frame owner, boolean b) {
		super(owner);
		initialize();
		setVisible(b);
	}

	/**
	 * This method initializes this
	 *
	 * @return void
	 */
	private void initialize() {
		this.setSize(587, 456);
		this.setTitle("Bank-Anwendung - Überweisung durchführen");
		this.setContentPane(getJContentPane());
	}

	/**
	 * This method initializes jContentPane
	 *
	 * @return javax.swing.JPanel
	 */
	private JPanel getJContentPane() {
		if (jContentPane == null) {
			jLabel = new JLabel();
			jLabel.setBounds(new Rectangle(30, 30, 120, 16));
			jLabel.setText("Von Konto");

			jLabel1 = new JLabel();
			jLabel1.setBounds(new Rectangle(30, 60, 120, 16));
			jLabel1.setText("Nach Konto");

			jLabel2 = new JLabel();
			jLabel2.setBounds(new Rectangle(30, 90, 120, 16));
			jLabel2.setText("Datum");

			jLabel3 = new JLabel();
			jLabel3.setBounds(new Rectangle(30, 120, 120, 16));
			jLabel3.setText("Betrag");

			jContentPane = new JPanel();
			jContentPane.setLayout(null);
			jContentPane.add(jLabel, null);
			jContentPane.add(jLabel1, null);
			jContentPane.add(jLabel2, null);
			jContentPane.add(jLabel3, null);
			jContentPane.add(getTfKontoVon(), null);
			jContentPane.add(getTfKontoNach(), null);
			jContentPane.add(getTfDatum(), null);
			jContentPane.add(getTfBetrag(), null);
			jContentPane.add(getBtDatum(), null);
			jContentPane.add(getBtUeberweisung(), null);
			jContentPane.add(getBtEnde(), null);
		}
		return jContentPane;
	}

	/**
	 * This method initializes tfKontoVon
	 *
	 * @return javax.swing.JTextField
	 */
	public JTextField getTfKontoVon() {
		if (tfKontoVon == null) {
			tfKontoVon = new JTextField();
			tfKontoVon.setBounds(new Rectangle(165, 30, 165, 17));
			ComponentUtil.addEnterKeyDelegator(tfKontoVon, getBtUeberweisung());
		}
		return tfKontoVon;
	}

	/**
	 * This method initializes tfKontoNach
	 *
	 * @return javax.swing.JTextField
	 */
	public JTextField getTfKontoNach() {
		if (tfKontoNach == null) {
			tfKontoNach = new JTextField();
			tfKontoNach.setBounds(new Rectangle(165, 60, 165, 17));
			ComponentUtil.addEnterKeyDelegator(tfKontoNach, getBtUeberweisung());
		}
		return tfKontoNach;
	}

	/**
	 * This method initializes tfDatum
	 *
	 * @return javax.swing.JTextField
	 */
	public JTextField getTfDatum() {
		if (tfDatum == null) {
			tfDatum = new JTextField();
			tfDatum.setBounds(new Rectangle(165, 90, 165, 17));
			tfDatum.setEditable(false);
			tfDatum.addFocusListener(new FocusHandler());
		}
		return tfDatum;
	}

	/**
	 * This method initializes tfBetrag
	 *
	 * @return javax.swing.JTextField
	 */
	public JTextField getTfBetrag() {
		if (tfBetrag == null) {
			tfBetrag = new JTextField();
			tfBetrag.setBounds(new Rectangle(165, 120, 165, 17));
			ComponentUtil.addEnterKeyDelegator(tfBetrag, getBtUeberweisung());
		}
		return tfBetrag;
	}


	/**
	 * This method initializes btÜberweisung
	 *
	 * @return javax.swing.JButton
	 */
	public JButton getBtUeberweisung() {
		if (btUeberweisung == null) {
			btUeberweisung = new JButton();
			btUeberweisung.setBounds(new Rectangle(345, 120, 132, 24));
			btUeberweisung.setText("Überweisen");
			ComponentUtil.addDefaultButtonBehaviour(btUeberweisung);
		}
		return btUeberweisung;
	}

	/**
	 * This method initializes btDatum
	 *
	 * @return javax.swing.JButton
	 */
	public JButton getBtDatum() {
		if (btDatum == null) {
			btDatum = new JButton();
			btDatum.setBounds(new Rectangle(345, 90, 132, 24));
			btDatum.setText("Datum auswählen");
            ComponentUtil.addDefaultButtonBehaviour(btDatum);
		}
		return btDatum;
	}

	/**
	 * This method initializes btEnde
	 *
	 * @return javax.swing.JButton
	 */
	public JButton getBtEnde() {
		if (btEnde == null) {
			btEnde = new JButton();
			btEnde.setBounds(new Rectangle(345, 150, 132, 24));
			btEnde.setText("Beenden");
            ComponentUtil.addDefaultButtonBehaviour(btEnde);
		}
		return btEnde;
	}


    // Inner Classes ***********************************************************

    private class FocusHandler implements FocusListener {

        @Override
        public void focusGained(FocusEvent e) {
            ((JComponent) e.getSource()).transferFocus();
        }

        @Override
        public void focusLost(FocusEvent e) {
        }
    }
}
